﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using PilotProject;
using PilotMVC.Models;

namespace PilotMVC.Controllers
{
    //[Authorize(Roles = "Admin")]
    public class HomeController : Controller
    {
        //private PilotEntities1 db = new PilotEntities1();

        public ActionResult Index()
        {
            return View();
        }

        //[HttpPost]
        //public ActionResult ManageCandidate(string jpa, string firstName, string lastName)
        //{
        //    var candidate = new ManageCandidateView();
        //    using (var context = new PilotEntities1())
        //    {
        //        if (!string.IsNullOrEmpty(jpa) && !jpa.Equals(""))
        //        {
        //            candidate.Candidate = context.People.OfType<Candidate>().Where(e => e.LastName.Contains(jpa)).SingleOrDefault();
        //        }
        //        if (!string.IsNullOrEmpty(firstName) && !firstName.Equals(""))
        //        {
        //            candidate.Candidates = context.People.Include("Address").OfType<Candidate>().Where(e => e.FirstName.ToLower().Contains(firstName.ToLower())).ToList();
        //        }
        //        if (!string.IsNullOrEmpty(lastName) && !lastName.Equals(""))
        //        {
        //            candidate.Candidates = context.People.Include("Address").OfType<Candidate>().Where(e => e.LastName.ToLower().Contains(lastName.ToLower())).ToList();
        //        }

        //        return View(candidate);
        //    }
        //}


        ////[HttpPost]
        //public ActionResult UpdateDetails(Guid id)
        //{
        //    var candidate = new ManageCandidateView();
        //    using (var context = new PilotEntities1())
        //    {
        //        candidate.Candidate = context.People.OfType<Candidate>().Where(i => i.Id.Equals(id)).SingleOrDefault();
        //        candidate.Address = candidate.Candidate.Address;
        //        candidate.Suburb = candidate.Candidate.Address.Suburb;
        //       // candidate.State = candidate.Candidate.state;

        //        //var tempUser = new User { usr_id = user.usr_id };
        //        //context.Users.Attach(tempUser);
        //        //context.ApplyCurrentValues("Users", user);
        //        //context.SaveChanges();
        //    }
        //    return View(candidate);
        //}





   
    }
}
